(function(){
	Ext.define('App.view.extend.fieldset.WithButtonFieldSet',{
		extend:'Ext.form.Panel',
		alias:'widget.withbuttonfieldset',
		title:'通过按钮添加内容',
		items:[
			{
				xtype:'button',
				text:'添加',
				handler:function(){
					this.up('withbuttonfieldset').addComIntoFs();
				}
			},
			{
				xtype:'fieldset',
		        title: '详细', // title or checkboxToggle creates fieldset header
//		        columnWidth: 0.5,
//		        checkboxToggle: false,
//		        collapsed: true, // fieldset initially collapsed
		        layout:'anchor',
		        name:'fs',
		        items :[]
			}
		],
		addComIntoFs:function(){
			var fs = this.down('[name=fs]');
			fs.add(new Ext.create('ChildComponent',{
				parentCom:fs
			}));
			fs.doLayout();
		}
	})
	
	Ext.define('ChildComponent',{
		extend:'Ext.form.Panel',
		alias:'widget.childcomponent',
		layout:'hbox',
		padding:'5 5 5 5',
		border:0,
		parentCom:null,
		items:[
			{
				xtype:'panel',
				border:0,
				flex:1,
				layout:'anchor',
				defaults:{xtype:'textfield',anchor:'100%',labelWidth:40,margin:'0 10 0 0'},
				items:[
					{
						xtype:'textfield',
						childname: 'name',
		        		fieldLabel: 'name'
					}
				]
			},{
				xtype:'panel',
				border:0,
				width:40,
				layout:'anchor',
				items:[
					{
						xtype:'button',
						text:'删除',
						handler:function(){
							var me = this.up('childcomponent');
							var par = me.parentCom;
							par.remove(me);
							par.doLayout();
						}
					}
				]
			}
		]
	})
	
})()